<?php
// View for event
require_once WACT_ROOT.'controller/controller.inc.php';
require_once WACT_ROOT .'controller/form.inc.php';
require_once WACT_ROOT.'view/view.inc.php';
require_once WACT_ROOT .'view/formview.inc.php';

require_once APP_ROOT . 'view/common/layout.formview.php';
require_once APP_ROOT . 'view/common/layout.view.php';
require_once APP_ROOT . 'include/inc.config.php';

require_once 'model/common/user.php';
require_once 'model/common/event.php';
require_once 'model/common/categories.php';
require_once 'model/common/date.php';
require_once 'model/common/price.php';

class EventView extends LayoutFormView {

	//var $form; // form controller

    function EventView($TemplateFile) {
        parent :: LayoutFormView($TemplateFile);
    }

    function prepare(&$controller, &$request, &$responseModel) {
    	parent::prepare($controller, $request, $responseModel);
    	//print 'Preparing view page...';
    	//$docbase = HOST;
		//$this->Template->set('docbase',$docbase);
		$app_name = APP_NAME;
		$this->Template->set('app_name',$app_name);
    	$template =& $this->Template;
		        
		$this->Template->set('SITE_CSS',Site::getSiteTemplateCSS());
		$this->Template->set('SITE_BASE',Site::getSiteTemplateBase());
		$this->Template->set('SITE_TITLE',Site::getTitle());
		$this->Template->set('title',Site::getTitle().' - calendar event details view');

 
    	//$price = Price::getPrice(4);
    	//$template->set('price',$price);

        // load event info
        $pending_event_id = $request->getParameter('pending_event_id');
        if (  $pending_event_id ) {
           $responseModel->set( 'pending_event_id',$pending_event_id);
           $record =& PendingEvent::getRecord($pending_event_id);
           if (is_null( $record )) return 'success';
           $responseModel->merge($record->export());
        }

        //$responseModel->set('price',$price);

		$price =& Price::getPrice(4);
		$price1 =& Price::getPrice(1);
		$price2 =& Price::getPrice(2);
		$price3 =& Price::getPrice(3);
                
		$price = number_format($price,2);
		$price1 = number_format($price1,2); 
		$price2 = number_format($price2,2);  
		$price3 = number_format($price3,2);
		$responseModel->set('price',$price);
		$responseModel->set('price1',$price1);
		$responseModel->set('price2',$price2);
		$responseModel->set('price3',$price3);


        if(!Session::isLogin()) {
    		$this->Template->set('login',' ');
            $responseModel->set('login',' ');
    	} else {
    		$responseModel->remove('login');
    	}

    	$occurance = Event::getEventOccurance($responseModel);
    	//$this->Template->set('occurance',$occurance);
    	$responseModel->set('occurance',$occurance);

    	$event_date = $responseModel->get('event_date');
    	$ts = strtotime( $event_date );
        $tz =& new MyTimeZone();
        $ts = $tz->timeGMT($ts);

    	$str_date = gmdate('m/d/Y',$ts);
    	$month = (integer)gmdate('m',$ts);
    	$year = (integer)gmdate('Y',$ts);
    	$responseModel->set('month',$month);
        $responseModel->set('year',$year);
        $responseModel->set('event_date',$str_date);

        //print_r(   $responseModel );


    	return;

   }

}






?>
